﻿using GalaSoft.MvvmLight;
using LightOMator.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LightOMator.ViewModel
{
    public class ObservableFadeCollection : ObservableObject
    {
        private string _name;
        public string Name
        {
            get { return _name; }
            set 
            {
                if (value != _name)
                {
                    _name = value;
                    RaisePropertyChanged();
                }
            }
        }

        private FadeMode _fadeMode;
        public FadeMode FadeMode
        {
            get { return _fadeMode; }
            set 
            {
                if (value != _fadeMode)
                {
                    _fadeMode = value;
                    RaisePropertyChanged();
                }
            }
        }

        private ObservableCollection<ObservableFade> _fades;
        public ObservableCollection<ObservableFade> Fades
        {
            get { return _fades; }
            set { _fades = value; }
        }

        public ObservableFadeCollection()
        {
        }

        public ObservableFadeCollection(FadeCollection collection)
        {
            _name = collection.Name;
            _fadeMode = collection.FadeMode;
            _fades = new ObservableCollection<ObservableFade>();
            foreach (Fade fade in collection.Fades)
            {
                _fades.Add(new ObservableFade(fade));
            }
        }

        public void ToFadeCollection(FadeCollection original)
        {
            original.Name = _name;
            original.FadeMode = _fadeMode;
            original.Fades.Clear();
            foreach (ObservableFade fade in _fades)
            {
                original.Fades.Add(fade.ToFade());
            }
        }
    }
}
